package api

import (
	"gorm/data"
	"log"
	"strconv"
	"time"

	"github.com/gin-gonic/gin"
)

func SaveUser(c *gin.Context) {
	user := &data.User{
		Username:   "zhangsan",
		Password:   "123456",
		CreateTime: time.Now(),
		UpdateTime: time.Now(),
	}
	data.Save(user)
	c.JSON(200, user)
}

func GetUserById(c *gin.Context) {
	id, err := strconv.Atoi(c.Param("id"))
	userInfo := data.GetById(id)
	if err != nil {
		log.Println("err!!!")
	}
	c.JSON(200, userInfo)
}
